<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	      <title>订单信息管理</title>
		  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		  <link rel="stylesheet" type="text/css" href="<%=basePath%>CSS/layout.css" />
          <script type="text/javascript" src="<%=basePath%>js/jquery.js"language="javascript"></script>
          <script language="javascript" type="text/javascript" src="<%=basePath%>js/displayLayer.js"></script>
          <script language="javascript" type="text/javascript" src="<%=basePath%>js/calendar.js"></script>
          <script language="javascript" type="text/javascript" src="<%=basePath%>js/popupdiv_shim.js"></script>
          <script language="javascript" type="text/javascript" src="<%=basePath%>js/ajaxPopup.js"></script>
           <script type="text/javascript" language="javascript">
           function showItems(cmtOrderId){
              window.open("<%=basePath%>getOrder.do?orderId="+cmtOrderId, "_blank");
           }
           var first=true;
           
           $(document).ready(function(){
            $("#addButton").toggle(
                function(){
                    if(first){
                      first=false;
                    }
                    addItems();
                },function(){
                    remove();
             });
           });
             var remove = function(){
               $("#items").attr("style","visibility: hidden;background-color: lightgreen;");
               $("#addItemFlag").attr("value","");
               $("#addButton").attr("value","<fmt:message key="order.addItem"/>");
             };
             
             var addItems = function(){
               $("#items").attr("style","visibility: visible;background-color: lightgreen;");
               $("#addItemFlag").val("add_items");
               $("#addButton").attr("value","<fmt:message key="order.cancelAdd"/>");
             };
             
             function delItem(trId){
               $("#"+trId).remove();
             }
             
             function addMore(){
               var itemTrs=$("#itemTable tr").lengtd;
               var addTr="<tr id='item"+itemTrs+"'>";
               addTr+="<td><input type='text' name='cmtPdtId'/></td>";
               addTr+="<td><input type='text' name='cmtPdtOrderId'/></td>";
               addTr+="<td><input type='text' name='attribute'/></td>";
               addTr+="<td><input type='text' id='sendDate"+itemTrs+"' name='sendDate' onclick='fPopCalendar(document.getElementById(\"sendDate"+itemTrs+"\"),document.getElementById(\"sendDate"+itemTrs+"\"));return false;' onkeydown='iniTxt_OnKeydown(event,tdis);'/></td>";
               addTr+="<td><input type='text' name='orderNum'/></td>";
               addTr+="<td><input type='button' value='<fmt:message key="pdtOrder.remove"/>' onclick='delItem(\"item"+itemTrs+"\")'/></td>";
               addTr+="</tr>";
               $("#itemTable").append(addTr);
             }
           </script>
  </head>
  <body>
  <div id="wrapper">
    <!--头部菜单开始-->
    <jsp:include page="/common/head.jsp"></jsp:include>
    <!--头部菜单结束-->
	<div id="BreadCrumb">我的位置：订单管理 &gt; 订单信息管理</div>
	<div id="REC_content">
	    <fieldset id="BasicInfo" class="mainField">
		    <legend><span class="title">订单信息管理</span></legend>
			<div class="innerCon">
			    <div class="mainSearchBox">
			       <form:form action="order.do" metdod="post" modelAttribute="vo" name="orderForm">
			       <table width="100%" cellpadding="0" cellspacing="0" border="0" class="editTab">
					<tr height="35">
						<td width="80" class="title"><fmt:message key="order.cmtorderid"/></td>
						<td align="left"><form:input path="cmtorderid"/></td>
						<td width="80" class="title"><fmt:message key="order.cmtwarehouse"/></td>
						<td align="left"><form:input path="cmtwarehouse"/></td>
						<td width="80" class="title"><fmt:message key="order.orderdate"/></td>
						<td align="left"><form:input id="orderdate" path="orderdate" onclick="fPopCalendar(document.getElementById('orderdate'),document.getElementById('orderdate'));return false;" onkeydown="iniTxt_OnKeydown(event,tdis);"/></td>
					</tr>
					<tr height="35">
						<td width="80" class="title"><fmt:message key="order.ordertype"/></td>
						<td align="left"><form:input path="ordertype"/></td>
						<td width="80" class="title"><fmt:message key="order.paytype"/></td>
						<td align="left"><form:input path="paytype"/></td>
						<td width="80" class="title"><fmt:message key="order.remark"/></td>
						<td align="left"><form:input path="remark"/></td>
					</tr>
					<tr>
					  <td colspan="6">
					   <div id="items" style="visibility: hidden;" >
                          <table id="itemTable" width="300" cellpadding="0" cellspacing="0" border="0" class="editTab">
                            <tr>
                             <td><fmt:message key="pdtOrder.cmtPdtId"/></td>
                             <td><fmt:message key="pdtOrder.cmtPdtOrderId"/></td>
                             <td><fmt:message key="pdtOrder.attribute"/></td>
                             <td><fmt:message key="pdtOrder.sendDate"/></td>
                             <td><fmt:message key="pdtOrder.orderNum"/></td>
                             <td>&nbsp;</td>
                            </tr>
                           <tr id="item1">
                            <td><input type="text" name="cmtPdtId"/></td>
                            <td><input type="text" name="cmtPdtOrderId"/></td>
                            <td><input type="text" name="attribute"/></td>
                            <td><input type="text" id="sendDate" name="sendDate" onclick="fPopCalendar(document.getElementById('sendDate'),document.getElementById('sendDate'));return false;" onkeydown="iniTxt_OnKeydown(event,tdis);"/></td>
                            <td><input type="text" name="orderNum"/></td>
                            <td><input type="button" class="newSearchButton" value="<fmt:message key="pdtOrder.addmore"/>" onclick="addMore()"/></td>
                          </tr>
                        </table>
                        </div>
                     </td>
					</tr>
					<tr id="moresearchCon">
						<td colspan="5"  align="left">
						  <input type="submit" name="searchButton" class="newSearchButton" value="新增" onclick="create()"/> 
						  <input type="button" name="searchButton" class="newSearchButton" value="查询" onclick="document.orderForm.action='orderQuery.do';document.orderForm.submit();"/> 
						  <input class="newSearchButton" id="addButton" type="button" value='<fmt:message key="order.addItem"/>' onclick="addItems()" />
                          <input type="hidden" name="addItemFlag" id="addItemFlag"/>
						</td>
					</tr>
				</table>
				</form:form>
			    </div>
			    
			    <!-- begin tab -->
			    <div class="topControl clearfix">
				    <div id="JobsMgrTabCon" class="itemTabCon">
					    <ul id="JobsMgrTabs" class="itemTabs">
							<li id="dueTab" class="focus"><a href="<%=basePath%>order.do" onfocus="tdis.blur()">订单信息管理</a></li>
							<li id="dueTab" class="blur"><a href="<%=basePath%>orderReview.do">订单信息导入</a></li>
					    </ul>
				    </div>
			    </div>
			    
			    
			    <!-- end tab -->
				<div id="mainListCon">
				    <div id="mLC">
					    <ul>
						    <li id="result">
							    <table width="888" style="border:1px solid #eee;" cellpadding="0" cellspacing="1" >
								    <tr bgcolor="#f2f6f9">
								        <td><fmt:message key="order.cmtorderid"/></td>
                                        <td><fmt:message key="order.cmtwarehouse"/></td>
                                        <td><fmt:message key="order.orderdate"/></td>
                                        <td><fmt:message key="order.ordertype"/></td>
                                        <td><fmt:message key="order.paytype"/></td>
                                        <td><fmt:message key="order.remark"/></td>
                                        <td><fmt:message key="order.totalNum"/></td>
                                        <td><fmt:message key="order.fileAddr"/></td>
									</tr>
									
									<c:forEach var="order" items="${dataList.pageList}" varStatus="idx">
									   <tr class="${idx.index%2==0?'list1':'list2'}" id="order${order.cmtorderid}">
                                         <td><a href="#" onclick="javascript:showItems('${order.cmtorderid}')">${order.cmtorderid}</a></td>
                                         <td>${order.cmtwarehouse==null?"&nbsp;":order.cmtwarehouse}</td>
                                         <td><fmt:formatDate value="${order.orderdate}"/></td>
                                         <td>${order.ordertype==null?"&nbsp;":order.ordertype}</td>
                                         <td>${order.paytype==null?"&nbsp;":order.paytype}</td>
                                         <td>${order.remark==null?"&nbsp;":order.remark}</td>
                                         <td>${order.totalNum}</td>
                                         <td><a href="${order.fileAddr}" target="_blank">下载</a></td>
                                      </tr>
									</c:forEach>
								</table> 
							</li>
						</ul>
					</div>
				</div>
			</div>
		</fieldset>
	</div>
	<jsp:include page="/common/foot.jsp"></jsp:include>
</div> 
</body>
</html>
